Skip to content
  • 0 Votes
    13 Posts
    64 Views
    Pl45m4P

    @Mark81 said in Catch mouse click on dummy row for QTabelView (returned by proxy but not in real model):

    That's odd, are we seeing the same repo?

    Yes, definitely.

    Now I see 31 open, 28 closed (same as @JonB , still no #62)

    Issue62.png

    Sorry I couldn't resist:
    The movie scene should be well-known :))

    9bli1m.jpg

  • 0 Votes
    8 Posts
    300 Views
    JonBJ

    @SergeyK12
    Are you aware that in a QStandardItemModel you can create a parent-child hierarchy? E.g. start from https://doc.qt.io/qt-6/qstandarditemmodel.html#details and QStandardItemModel::insertRow(int row, const QModelIndex &parent = QModelIndex()) etc.

    So why don't you store your model like that if it's hierarchical?

    Unless you mean you start with a QStandardItemModel which is flat and multi-column like the first one, for whatever reason, and want to display that in the second way. For that yes a proxy like yours would be good.

  • 0 Votes
    6 Posts
    687 Views
    VikramSamyV

    @JonB said in TableView not updated or refreshed unless column is resized and scroll bar move up and down few times:

    @VikramSamy
    I don't know, but a couple of observations:

    You are using a QSqlTableModel, so it should be emitting all the dataChanged() and rowsInnserted() signals itself. I would remove all your emits.
    YES REMOVED

    HistoryProxyModel->setDynamicSortFilter(false);: try setting this to true, any difference?
    NO, I need to disable the-sorting mechanism in the proxy model and do the sorting in the SQL Table model itself before I initialize table-model as the source-model for the Qsortproxymodel

    If you remove your proxy model temporarily does everything work?
    Ya the the VIEW is updated properly if proxy model is removed.

    Try starting from a Qt example with model + proxy model, does that work? YES I DID

    After a long gap, i just started to check this issue again,
    the previous behavior of the Table View was due to the flow of my code and it is because descending order SORTING mechanism enabled in the proxy-model, this caused the behavior as in 1st post. T

    //this was the issue HistoryProxyModel->setDynamicSortFilter(true); HistoryProxyModel->sort(1,Qt::DescendingOrder);

    As I wanted to show the last row as first row in the Table View, I enabled the DescendingOrder sorting in the proxy model first and then apply filtering, and this was the issue .

    but then I enabled the descending Order sorting on the SQL Table Model and Disabled it on the proxy model,
    now all works fine, The proxy model just do the filtering's only. i added the code below on my Qsql Table Model.

    //this was the solution - sort the Table model TableModel->setSort(1,Qt::DescendingOrder);

    and so i removed the sorting codes at the proxy model .
    I removed the below code:-

    //removed from proxy codes //HistoryProxyModel->sort(1,Qt::DescendingOrder)

    and now so far all works fine....